Providing a straightforward way to analyse data, these packages are widely used in machine learning.
Pandas is one of the most used libraries for data manipulation:
https://pandas.pydata.org
Plotly http://plotly.com is a package for interactive data
visualization,
here how to get it work
with jupyter lab
The service URL is nds.iaea.org/relnsd/v0/data?
followed by parameters. For example:
nds.iaea.org/relnsd/v0/data?fields=decay_rads&nuclides=241am&rad_types=g.
The API v0 guide gives the detailed
description, but the examples below are self explanatory
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
# the service URL
livechart = "https://nds.iaea.org/relnsd/v0/data?"
There have been cases in which the service returns an HTTP Error 403: Forbidden
In this case use the following workaround
import urllib.request
def lc_read_csv(url):
req = urllib.request.Request(url)
req.add_header('User-Agent', 'Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:77.0) Gecko/20100101 Firefox/77.0')
return pd.read_csv(urllib.request.urlopen(req))
fields=decay_rads specifies to retrieve the decay radiations, nuclides=241am
specifies the parent of the decay (241am), rad_types=g for the radiation type (gamma).
On the plot below, mouseover the points to see the data. Zoom an pan are enabled, and the
option to save as png is is activated when the mouse is over the top-right
# load data into a dataframe
# this loading might not work, then use the line below
#df = pd.read_csv(livechart + "fields=decay_rads&nuclides=241am&rad_types=g")
df = lc_read_csv(livechart + "fields=decay_rads&nuclides=241am&rad_types=g")
df = df[pd.to_numeric(df['intensity'],errors='coerce').notna()] # remove blanks (unknown intensities)
df.intensity = df['intensity'].astype(float) # convert to numeric. Note how one can specify the field by attribute or by string
fig = px.scatter(df, x="energy", y="intensity", log_y=True) # plot in log scale
fig.show()
The fields to be retieved are decay_rads, the nuclide is 100-Nb, and the radiation type is bm
In this case, only the relevant fields are loaded into the dataset; then data are grouped by transition, binned,
and plotted
The transition types in the plot legend are not decoded. A stands for Allowed, 1NU for 1st non unique, ...
url = livechart+"fields=decay_rads&nuclides=100nb&rad_types=bm"
# this loading might not work, then use the line below
#df=pd.read_csv(url)[['transition_type','log_ft']] # optional:load only transition_type and log_ft
df=lc_read_csv(url)[['transition_type','log_ft']] # optional:load only transition_type and log_ft
df = df[pd.to_numeric(df.log_ft,errors='coerce').notna()] # remove unknowns and convert to numeric values
df.log_ft = df.log_ft.astype(float)
ans = [pd.DataFrame(y) for x, y in df.groupby('transition_type', as_index=False)] # group log ft values by transition
fig = go.Figure()
for a in ans:
ct = pd.cut(a.log_ft, bins=10) # bin each grouping
tst = ct.apply(lambda x: x.mid).value_counts(sort=False) # assign the mid value to each bin
fig.add_trace(go.Scatter(x=tst.index.values, y = tst, mode="markers", line_shape='spline', name=a.transition_type.iloc[0]))
fig.show()
The pandas query function acts on the loaded dataset.
To plot the Half-life of Ac isotopes, apply the query function to the column symbol to extract
the Ac isotopes
.query('symbol=="Ac"')
url=livechart+"fields=ground_states&nuclides=all"
# this loading might not work, then use the line below
#df=pd.read_csv(url)[['symbol','n','half_life_sec']].query('symbol=="Ac"') # further filter
df=lc_read_csv(url)[['symbol','n','half_life_sec']].query('symbol=="Ac"') # further filter
fig = px.scatter(df, x="n", y="half_life_sec", log_y=True)
fig.show()
Use the mouse to rotate and zoom
url=livechart+"fields=cumulative_fy&parents=235u"
# this loading might not work, then use the line below
#df = pd.read_csv(url) [['z_daughter','a_daughter',"element_daughter",'cumulative_fast_fy']]
df = lc_read_csv(url) [['z_daughter','a_daughter',"element_daughter",'cumulative_fast_fy']]
df = df[pd.to_numeric(df.cumulative_fast_fy,errors='coerce').notna()]
df.cumulative_fast_fy = df.cumulative_fast_fy.astype(float)
fig = go.Figure(data=[go.Scatter3d(
x=df["z_daughter"],
y=df["a_daughter"]-df["z_daughter"],
z=df["cumulative_fast_fy"],
mode='markers',
text = df['a_daughter'].apply(str) + df["element_daughter"],
marker=dict(
size=7
,color=df["cumulative_fast_fy"] # array/list of values setting the color
,colorscale='Viridis' # colorscale
)
)])
camera = dict( # initial spacial settings
up=dict(x=0, y=0, z=1),
center=dict(x=0, y=0, z=0),
eye=dict(x=0.1, y=2, z=-1.5) # view it from the bottom
)
fig.update_layout(scene_camera=camera, margin=dict(l=0, r=0, b=0, t=0), height=900)
fig.show()
# 2D plot
fig2 = go.Figure()
fig2.add_trace(go.Scatter( x=df[df.columns[1]], y=df['cumulative_fast_fy'], mode="markers", text= df['a_daughter'].apply(str) + df["element_daughter"]))
fig2.update_layout( height=1000, xaxis_title="A", yaxis_title="Yield ")
fig2.show()
• Ground state
pd.set_option('display.max_columns', None)
pd.set_option("display.max_rows", 3)
# GS
df=pd.read_csv(livechart+"fields=ground_states&nuclides=236np")
df
| z | n | symbol | radius | unc_r | energy_shift | energy | unc_e | ripl_shift | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay_1 | decay_1_% | unc_1 | decay_2 | decay_2_% | unc_2 | decay_3 | decay_3_% | unc_3 | isospin | magnetic_dipole | unc_md | electric_quadrupole | unc_eq | qbm | unc_qb | qbm_n | unc_qbmn | qa | unc_qa | qec | unc_qec | sn | unc_sn | sp | unc_sp | binding | unc_ba | atomic_mass | unc_am | mass excess | unc_me | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 93 | 143 | Np | NaN | 0 | (6-) | 153000.0 | 5 | Y | 4.828210e+12 | 1.577846e+11 | EC | 86.3 | 0.8 | B- | 13.5 | 0.8 | A | 0.16 | 0.04 | 476.5854 | 503887 | -6875.5708 | 54 | 5006.629 | 51 | 933.512 | 50 | 5736.2687 | 50 | 4829.6598 | 50 | 7579.2148 | 2136 | 2.360466e+08 | 54129 | 43378.094 | 50421 | 2021-08-27 |
• Level
Note the "X" in the energy_shift field for the 2nd level, and the value in the "ripl_shift" column (see the API guide for the meaning of the shift)
# LEVEL
df=pd.read_csv(livechart+"fields=levels&nuclides=236np")
df
| z | n | symbol | idx | energy_shift | energy | unc_e | ripl_shift | jp | jp_order | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hl.1 | decay_1 | decay_1_% | unc_1 | decay_2 | decay_2_% | unc_2 | decay_3 | decay_3_% | unc_3 | isospin | magnetic_dipole | unc_mn | electric_quadrupole | unc_eq | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 93 | 143 | Np | 0 | 0 | (6-) | 1 | 153E+3 | 5 | Y | 4828209674112.576 | 157784629872.96 | EC | 86.3 | 0.8 | B- | 13.5 | 0.8 | A | 0.16 | 0.04 | 2021-08-27 | |||||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 4 | 93 | 143 | Np | 4 | 324 | 50 | (5-) | 1 | 2021-08-27 |
5 rows × 31 columns
•Gamma
# GAMMA transitions
df=pd.read_csv(livechart+"fields=gammas&nuclides=135xe")
df
| z | n | symbol | start_level_idx | start_level_energy | unc_sle | start_level_jp | end_level_idx | end_level energy | unc_ele | end_level_jp | gamma_idx | energy | unc_en | relative_intensity | unc_ri | multipolarity | mixing_ratio | unc_mr | b_e1 | unc_be1 | b_e2 | unc_be2 | b_m1 | unc_bm1 | b_m2 | unc_bm2 | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 54 | 81 | Xe | 1 | 288.455 | 0.015 | 1/2+ | 0 | 0.0 | 3/2+ | 0 | 288.451 | 0.016 | 100.0 | [M1 E2] | 2021-08-27 | ||||||||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 96 | 54 | 81 | Xe | 37 | 3169.900 | 0.900 | 26 | 2356.5 | 0.8 | 1 | 813.400 | 0.9 | 75.0 | 20 | 2021-08-27 |
97 rows × 28 columns
•Cumulative fission
# CUMULATIVE_FISSION
df=pd.read_csv(livechart+"fields=cumulative_fy&products=135xe")
df
| z_daughter | a_daughter | element_daughter | z_parent | z_parent.1 | element_parent | metastable | cumulative_thermal_fy | unc_ct | cumulative_fast_fy | unc_cf | cumulative_14mev_fy | unc_c14 | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 54 | 135 | Xe | 92 | 235 | U | 0 | 0.06614 | 0.002249 | 0.06321 | 0.001833 | 0.064242 | 0.018117 | 2021-08-27 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 15 | 54 | 135 | Xe | 94 | 241 | Pu | 1 | 0.012532 | 0.0013048 | 0.01377 | 0.001443 | 2021-08-27 |
16 rows × 14 columns
•Independent fission
# INDEPENDENT FISSION
df=pd.read_csv(livechart+"fields=independent_fy&parents=235u")
df
| z_daughter | a_daughter | element_daughter | z_parent | a_parent | element_parent | metastable | independent_thermal_fy | unc_it | independent_fast_fy | unc_if | independent_14mev_fy | unc_i14 | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 1 | 1 | H | 92 | 235 | U | 0 | 0.00001711 | 0.0000029483 | 0.000026891 | 0.0000091812 | 0.000026369 | 0.0000090796 | 2021-08-27 |
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 1230 | 72 | 179 | Hf | 92 | 235 | U | 0 | 0 | 0 | 2021-08-27 |
1231 rows × 14 columns
•Decay radiation
# DECAY_RADIATION, type alpha
df=pd.read_csv(livechart+"fields=decay_radiations&nuclides=238u&rad_types=a")
df
| 3 |
|---|
# DECAY_RADIATION, type gamma
df=pd.read_csv(livechart+"fields=decay_rads&nuclides=238u&rad_types=g")
df
| energy | unc_en | intensity | unc_i | start_level_energy | end_level_energy | multipolarity | mixing_ratio | unc_mr | conversion_coeff | unc_cc | p_z | p_n | p_symbol | p_energy_shift | p_energy | unc_pe | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay | decay_% | unc_d | q | unc_q | d_z | d_n | d_symbol | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 44.915 | 0.0 | E2 | NaN | 92 | 146 | U | 2557.9 | 0.5 | 0+ | 2.800000e+02 | 6 | ns | 2.800000e-07 | 6.000000e-09 | IT | 97.4 | 0.4 | NaN | 92 | 146 | U | 2021-08-27 | NaN | |||||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 13 | 108.580 | 0.000134 | 92 | 146 | U | 0.0 | 0+ | 4.468000e+09 | 6 | Y | 1.409963e+17 | 1.893416e+14 | A | 100.0 | 4269.9 | 2.1 | 90 | 144 | Th | 2021-08-27 | NaN |
14 rows × 33 columns
# DECAY_RADIATION, type x-ray
df=pd.read_csv(livechart+"fields=decay_rads&nuclides=238u&rad_types=x")
df
| energy | unc_en | intensity | unc_i | type | shell | p_z | p_n | p_symbol | p_energy_shift | p_energy | unc_pe | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay | decay_% | unc_d | q | unc_q | d_z | d_n | d_symbol | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 15.784 | 7.300000 | X | L | 92 | 146 | U | 0 | 0+ | 4.468000e+09 | 6 | Y | 1.409963e+17 | 189341555847552 | A | 100 | 4269.9 | 2.1 | 90 | 144 | Th | 2021-08-27 | ||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 5 | 108.580 | 0.000134 | X | KpB2 | 92 | 146 | U | 0 | 0+ | 4.468000e+09 | 6 | Y | 1.409963e+17 | 189341555847552 | A | 100 | 4269.9 | 2.1 | 90 | 144 | Th | 2021-08-27 |
6 rows × 28 columns
# DECAY_RADIATION, type beta-
df=pd.read_csv(livechart+"fields=decay_rads&nuclides=135xe&rad_types=bm")
df
| mean_energy | unc_me | intensity_beta | unc_ib | daughter_level_energy | max_energy | unc_me.1 | log_ft | unc_lf | transition_type | anti_nu_mean_energy | unc_ame | p_z | p_n | p_symbol | p_energy_shift | p_energy | unc_pe | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay | decay_% | unc_d | q | unc_q | d_z | d_n | d_symbol | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 26.9 | 1.1 | 0.123 | 0.006 | 1062.42 | 103 | 4 | 5.71 | 0.06 | 76.0 | 2.9 | 54 | 81 | Xe | 0.000 | 3/2+ | 9.14 | 2 | h | 32904.0 | 72 | B- | 100.0 | 1169 | 4 | 55 | 80 | Cs | 2021-08-27 | |||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 9 | 641.4 | 1.7 | 0.600 | 0.600 | 0.00 | 1692 | 4 | 8.50 | 1U | 605.2 | 3.5 | 54 | 81 | Xe | 526.551 | 0.013 | 11/2- | 15.29 | 5 | m | 917.4 | 3 | B- | 0.6 | 1169 | 4 | 55 | 80 | Cs | 2021-08-27 |
10 rows × 34 columns
# DECAY_RADIATION, type electron
df=pd.read_csv(livechart+"fields=decay_rads&nuclides=238u&rad_types=e")
df
| energy | unc_en | intensity | unc_i | type | shell | p_z | p_n | p_symbol | p_energy_shift | p_energy | unc_pe | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay | decay_% | unc_d | q | unc_q | d_z | d_n | d_symbol | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | 13.113 | 8.100000 | AU | L | 92 | 146 | U | 0 | 0+ | 4.468000e+09 | 6 | Y | 1.409963e+17 | 189341555847552 | A | 100 | 4269.9 | 2.1 | 90 | 144 | Th | 2021-08-27 | ||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 4 | 104.327 | 0.000004 | AU | KXY | 92 | 146 | U | 0 | 0+ | 4.468000e+09 | 6 | Y | 1.409963e+17 | 189341555847552 | A | 100 | 4269.9 | 2.1 | 90 | 144 | Th | 2021-08-27 |
5 rows × 28 columns
# DECAY_RADIATION, type beta+/electron capture
df=pd.read_csv(livechart+"fields=decay_rads&nuclides=236np&rad_types=bp")
df
| mean_energy | unc_me | intensity_beta | unc_ib | daughter_level_energy | energy_ec | unc_eec | intensity_ec | unc_ie | log_ft | unc_lf | transition_type | nu_mean_energy | unc_nme | p_z | p_n | p_symbol | p_energy_shift | p_energy | unc_pe | jp | half_life | operator_hl | unc_hl | unit_hl | half_life_sec | unc_hls | decay | decay_% | unc_d | q | unc_q | d_z | d_n | d_symbol | Extraction_date | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 0 | NaN | 149.46 | 781 | 50 | 6.04 | 0.06 | 15.7 | 1U | 93 | 143 | Np | 0 | (6-) | 153000.0 | 5 | Y | 4.828210e+12 | 1.577846e+11 | EC | 86.3 | 0.8 | 934 | 50 | 92 | 144 | U | 2021-08-27 | |||||||||
| ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... | ... |
| 5 | NaN | 309.79 | 620 | 50 | 74.50 | 1.00 | 14.1 | 1NU | 93 | 143 | Np | 0 | (6-) | 153000.0 | 5 | Y | 4.828210e+12 | 1.577846e+11 | EC | 86.3 | 0.8 | 934 | 50 | 92 | 144 | U | 2021-08-27 |
6 rows × 36 columns